package cn.iocoder.yudao.module.measure.service.upload.impl;


import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
import cn.iocoder.yudao.module.measure.dal.dataobject.upload.BusinessDeviceUploadData;
import cn.iocoder.yudao.module.measure.dal.mysql.upload.BusinessDeviceUploadDataMapper;
import cn.iocoder.yudao.module.measure.service.upload.BusinessDeviceUploadDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;


/**
 * <p>
 * 业务实现类
 * 设备上传数据解析结果表
 * </p>
 *
 * @author zhengbzh
 * @date 2025-05-26 14:52:16
 * @create [2025-05-26 14:52:16] [zhengbzh] [代码生成器生成]
 */
@Slf4j
@Service
@Validated
@Transactional(readOnly = true)
public class BusinessDeviceUploadDataServiceImpl implements BusinessDeviceUploadDataService {

    @Resource
    private BusinessDeviceUploadDataMapper businessDeviceUploadDataMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveBatch(Long tenantId, List<BusinessDeviceUploadData> dataList) {
        // 以指定租户身份存储数据
        log.debug("模拟租户存储设备上传的数据：{}",tenantId);
        TenantUtils.execute(tenantId, () -> {
            businessDeviceUploadDataMapper.insertBatch(dataList);
        });
    }
}


